package smb;

import static org.junit.Assert.assertTrue;

import robocode.BattleResults;
import robocode.control.events.BattleCompletedEvent;
import robocode.control.testing.RobotTestBed;

/**
 * Tests that PwnU2 beats Crazy 6 times out of 10
 * edited from professor Johnson code.
 * @author Shoji Bravo
 * 
 */
public class TestPwnUVsCrazy extends RobotTestBed {
 /**
  * Specifies that crazy and PwnU2 are to be matched up in this test case.
  * 
  * @return The comma-delimited list of robots in this match.
  */
 @Override
 public String getRobotNames() {
  return "sample.Crazy,smb.PwnU2";
 }

 /**
  * This test runs for 1 round.
  * 
  * @return The number of rounds.
  */
 @Override
 public int getNumRounds() {
  return 10;
 }

 /**
  * After the battle, check to see that we've visited the corners.
  * 
  * @param event
  *         Details about the completed battle.
  */
 @Override
 public void onBattleCompleted(BattleCompletedEvent event) {
  boolean battleWon = false;
  // Return the results in order of getRobotNames.
  BattleResults[] Results = event.getIndexedResults();
  BattleResults PwnU = Results[1];
  String robotName = PwnU.getTeamLeaderName();
    
 if (PwnU.getFirsts() >= 6) {
  battleWon = true;
 }
  assertTrue("Check that PwnU beat Crazy 6 times out of 10 ", battleWon);
  
  System.out.println(robotName + " won " + PwnU.getFirsts());
 }

}
